const Generator=require('yeoman-generator')
module.exports=class extends Generator{
  prompting(){
    return this.prompt([
      {
        type:'input',//接收的方式是用户的输入
        name:'name',//接收的值的键
        message:'project name?',//发出的问题
        default:this.appname//自定获取当前项目的文件夹名称
      }
    ]).then(answers=>{
      this.answers=answers
      // console.log('answers: ', answers);
    })
  }
  writing(){
    const pathArr=[  //模板文件夹下各个文件的路径
      '.editorconfig',
      '.gitignore',
      '.prettierignore',
      '.prettierrc',
      '.umirc.ts',
      'package.json',
      'README.md',
      'tsconfig.json',
      'typings.d.ts',
      'src/pages/index.less',
      'src/pages/index.tsx',
      'src/pages/g6/index.js',
      'src/pages/g6/input.js',
      'src/pages/g6/theme.js'
    ]
    //循环写入
    pathArr.forEach(item=>this.fs.copyTpl(this.templatePath(item),this.destinationPath(item),this.answers))
  }
}